package com.bosssoft.ct.springcloud.exception;

/**
 * 自定义业务异常
 * @author ChenTong
 * @version 1.0
 * @date 2020/6/22 7:29
 * @copyright
 * @modified
 * @see BusinessExceptionCode
 * @since
 **/
public class BusinessException extends RuntimeException{
    private final int code;

    public BusinessException(int code, String message) {
        super(message);
        this.code=code;
    }

    /**
     * 发生业务异常则构建异常对象抛出
     * @param code
     * @param message
     * @param cause
     */
    public BusinessException(int code, String message, Throwable cause) {
        super(message,cause);
        this.code=code;
    }

    public BusinessException(BusinessExceptionCode businessErrorCode, Throwable cause) {
        super(businessErrorCode.getMessage(),cause);
        this.code = businessErrorCode.getCode();
    }

    public int getCode(){
        return this.code;
    }
}
